<?php

//retrive shopping cart ID from cookie
$shoppingcart_id = $_COOKIE["shoppingcart_id"];

//we extract the items contained inside the cart
$cart_items = mysql_query("SELECT ID_ITEM, AMOUNT FROM rel WHERE ID_CART = '$shoppingcart_id'");

//the result is a table from which we will have to extract every item, represented by an array
while($cart_item = mysql_fetch_array($cart_items))
	{	
	//save the item's id in another variable
	$cart_item_id = $cart_item["ID_ITEM"];
	
	//to understand easely, we will save the quantity of the selected item too
	$cart_item_quantity = $cart_item["AMOUNT"];
	
	//now we have the item's ID. we extract it's details from the items table
	$item_details = mysql_query("SELECT NAME, PRICE, DESCRIPTION, IMAGE_URL FROM items WHERE id = '$cart_item_id'");
	
	//extract the vector containing the item details
	//the resulting table has only one row (only one item can have that ID)
	//we do not need WHILE again
	$item_details_array = mysql_fetch_array($item_details);
	
	//we now have the item details. we can display them to page
	?>
    <img src="<?php echo($item_details_array["IMAGE_URL"]); ?>" border="0" /><br />
    Item name: <?php echo($item_details_array["NAME"]); ?><br />
    Item description: <?php echo($item_details_array["DESCRIPTION"]); ?><br />
    Item price: <?php echo($item_details_array["PRICE"]); ?><br />
    Quantity: <?php echo($cart_item_quantity); ?><br />
    Item total cost: <?php echo($item_details_array["PRICE"] * $cart_item_quantity); ?><br /><br />
    <form action="mypage.php" method="get">
    	<input type="hidden" name="action" value="delete" />
    	<input type="hidden" name="item" value="<?php echo($item["ID"]); ?>" />
    	<input type="submit" value="Delete from cart" />
	</form>
    <?php
	}
	
?>